package Common_ArrayList_API;

import java.util.ArrayList;
import java.util.Scanner;


public class FoodManager {
    Scanner peo = new Scanner(System.in);
    ArrayList<Food> foods = new ArrayList<>();

    public void add() {
        System.out.println("==菜品上架==");
        Food food = new Food();
        System.out.println("请输入你要上架的菜品的名字");
        String name = peo.next();
        food.setName(name);
        System.out.println("请输入你要上架的菜品的原价");
        double price = peo.nextDouble();
        food.setOrignalPrice(price);
        System.out.println("请输入你要上架的菜品的优惠价");
        double price1 = peo.nextDouble();
        food.setSpecialPrice(price1);
        System.out.println("请输入描述信息");
        String info = peo.next();
        food.setInfo(info);
        foods.add(food);
    }

    public void printAllFood() {
        for (int i = 0; i < foods.size(); i++) {
            Food food = foods.get(i);
            System.out.println("菜品名称:" + food.getName());
            System.out.println("菜品原价:" + food.getOrignalPrice());
            System.out.println("菜品优惠价:" + food.getSpecialPrice());
            System.out.println("其他描述信息" + food.getInfo());
        }
    }

    public void start() {
        while (true) {
            System.out.println("====欢迎进入商家后台管理系统====");
            System.out.println("1.上架菜品(add)");
            System.out.println("2.浏览菜品(query)");
            System.out.println("3.退出系统(exit)");
            System.out.println("请选择操作命令");
            String command = peo.next();
            switch (command) {
                case "add":
                    add();
                    break;
                case "query":
                    printAllFood();
                    break;
                case "exit":
                    return;
                default:
                    System.out.println("输入错误");
            }
        }
    }
}
